function pfMakeup() {
  let Makeup
  let Venus

  function _getMakeup() {
    if (Makeup) {
      return Makeup
    } else {
      throw new Error('Makeup sdk not found, please call init first.')
    }
  }

  this.init = function(args) {
    Makeup = require('../pfEngine/loadModule/Makeup')
    Venus = require('../pfEngine/loadEngine/Venus')
    _getMakeup().init({
      perfectLib: args.perfectLib,
      venus: Venus,
      callback: args.callback,
      canvas: args.canvas,
      enableSkia: args.enableSkia
    })
  }

  this.unInit = function() {
    _getMakeup().unInit()
    Makeup = null
    Venus = null
  }

  this.processFrame = function(frame, isPhoto, callback) {
    _getMakeup().processFrame(frame, isPhoto, callback)
  }

  this.getListByEffect = function(type, start, callback) {
    _getMakeup().getListByEffect(type, start, callback)
  }

  this.getTaobaoId = function(item, callback) {
    _getMakeup().getTaobaoId(item, callback)
  }

  this.applyMakeupBySkus = function(skus, callback) {
    _getMakeup().applyMakeupBySkus(skus, callback)
  }

  this.getLooks = function(start, callback) {
    return _getMakeup().getLooks(start, callback)
  }

  this.applyMakeupByLook = function(look, callback) {
    _getMakeup().applyMakeupByLook(look, callback)
  }

  this.setRendererConfig = function(args) {
    _getMakeup().setRendererConfig(args)
  }

  this.clearEffects = function(types, callback) {
    _getMakeup().clearEffects(types, callback)
  }

  this.clearAllEffects = function(callback) {
    _getMakeup().clearAllEffects(callback)
  }

  this.takePicture = function(callback) {
    _getMakeup().takePicture(callback)
  }

  this.enableComparison = function(enable = true) {
    _getMakeup().enableComparison(enable)
  }

  this.setComparePosition = function(x = 0.5) {
    _getMakeup().setComparePosition(x)
  }

  this.getIntensities = function() {
    return _getMakeup().getIntensities()
  }

  this.setIntensities = function(map) {
    _getMakeup().setIntensities(map)
  }

  this.clearResources = function() {
    _getMakeup().clearResources()
  }

  this.getEffectIds = function() {
    return _getMakeup().getEffectIds()
  }

  this.getProductIds = function() {
    return _getMakeup().getProductIds()
  }
}

const makeupInstance = new pfMakeup()

module.exports = {
  init: makeupInstance.init,
  unInit: makeupInstance.unInit,
  processFrame: makeupInstance.processFrame,
  getTaobaoId: makeupInstance.getTaobaoId,
  applyMakeupBySkus: makeupInstance.applyMakeupBySkus,
  getLooks: makeupInstance.getLooks,
  applyMakeupByLook: makeupInstance.applyMakeupByLook,
  setRendererConfig: makeupInstance.setRendererConfig,
  clearEffects: makeupInstance.clearEffects,
  clearAllEffects: makeupInstance.clearAllEffects,
  takePicture: makeupInstance.takePicture,
  enableComparison: makeupInstance.enableComparison,
  setComparePosition: makeupInstance.setComparePosition,
  getIntensities: makeupInstance.getIntensities,
  setIntensities: makeupInstance.setIntensities,
  clearResources: makeupInstance.clearResources,
  getListByEffect: makeupInstance.getListByEffect,
  getEffectIds: makeupInstance.getEffectIds,
  getProductIds: makeupInstance.getProductIds
}
